import { createStore } from 'vuex'
import vuexp from 'vuex-persistedstate'

export default createStore({
  plugins:[vuexp()],
  state: {
    todolist: []
  },
  getters: {
  },
  mutations: {
    add(state,obj){
      state.todolist.push(obj)
      console.log(state.todolist);
    },
    flag(state,obj){
      obj.flag=!obj.flag;
    },
    del(state,id){
      let index = state.todolist.findIndex(item => item.id == id)
      console.log(index);
      state.todolist.splice(index, 1);
    }
  },
  actions: {
  },
  modules: {
  }
})
